﻿using System;
using System.Windows;
using System.Windows.Media;

namespace OurMind.Controls.Connectors
{

    ///<summary>水平直线连接符。</summary>
    public class HorizontalStraightLineConnector : BaseConnector
    {
        protected override void OnRender(DrawingContext dc)
        {
            var renderSize = RenderSize;

            Point startPoint;
            Point endPoint;

            switch (Direction)
            {
                case ConnectorDirectionEnum.LeftBottomToRightTop:
                    startPoint = new Point(0 + LineMargin, renderSize.Height - LineMargin);
                    endPoint = new Point(renderSize.Width - LineMargin, 0d + LineMargin);
                    break;
                case ConnectorDirectionEnum.LeftTopToRightBottom:
                    startPoint = new Point(0 + LineMargin, 0d + LineMargin);
                    endPoint = new Point(renderSize.Width - LineMargin, renderSize.Height - LineMargin);
                    break;
                default:
                    throw new NotImplementedException();
            }


            dc.DrawLine(LineBrush, startPoint, endPoint);
        }
    }
}
